package com.fdb.efp.nls.service.impl.ctrloancont.ctr;

import com.fdb.efp.nls.service.vo.sx.NlsCreditInfoVO;
import com.fdb.basic.framework.core.exception.BizException;
import com.fdb.efp.nls.common.psd.PsdConstantSet;
import com.fdb.efp.nls.service.vo.SOrgVO;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * 需求编号:2019D08--
 * 问题编号:
 * 开发人员: caoxin
 * 创建日期:2020/3/13
 * 功能描述:
 * 修改日期:2020/3/13
 * 修改描述:
 */
public abstract class AbstractCtrLoanCtrBean<T> {
    // 基本元素
    protected String inputPath;
    protected String outputPath;
    Map<String, String> ctrLoanContMedaData = new HashMap<>();
    // 共有元素
    //授信合同号
    //银行全称
    //机构地址
    //机构邮编
    //机构电话
    //客户姓名
    //证件类型
    //证件号码
    //客户住址
    //客户邮编
    //客户电话
    //客户传真
    //客户电子邮箱
    //签约日期 yyyy-MM-dd

    protected String lmtContNo;
    protected String orgName;
    protected String orgAddr;
    protected String orgZipcode;
    protected String orgTel;
    protected String cusName;
    protected String certType;
    protected String certCode;
    protected String cusAddr;
    protected String cusZipcode;
    protected String cusPhone;
    protected String cusTax;
    protected String cusEmail;
    protected String signDate;
    protected String contNo;
    protected String lmtAmtUpper;
    protected String lmtAmtLower;
    
    public AbstractCtrLoanCtrBean() {
    }

    protected String getInputPath() {
        return inputPath;
    }

    protected String getOutputPath() {
        return outputPath;
    }

    public Map<String, String> getCtrLoanContMetaData(NlsCreditInfoVO nlsCreditInfoVO, SOrgVO sOrgVO, T t) throws BizException {
        setSpecifiedLoanContMedaData(t);
        setCtrLoanContMedaData(nlsCreditInfoVO, sOrgVO);
        return ctrLoanContMedaData;
    }

    protected void addContMetaData(String key, String value) {
        ctrLoanContMedaData.put(key, value);
    }
    
    private void setCtrLoanContMedaData(NlsCreditInfoVO nlsCreditInfoVO, SOrgVO sOrgVO) {
        // 授信合同号
        addContMetaData("lmtContNo", nlsCreditInfoVO.getLmtApplySeq());
        //银行全称
        addContMetaData("orgName", sOrgVO.getOrgName());
        //机构地址
        addContMetaData("orgAddr", sOrgVO.getOrgAddress());
        //机构邮编
        addContMetaData("orgZipcode", sOrgVO.getOrgZipcode());
        //机构电话
        addContMetaData("orgTel", sOrgVO.getOrgTel());
        //机构地址
        addContMetaData("zhAddr", PsdConstantSet.ZH_ADDR);
        //机构邮编
        addContMetaData("zhZipcode", PsdConstantSet.ZH_POST);
        //机构电话
        addContMetaData("zhTel", PsdConstantSet.ZH_TEL);
        // 放款卡号
        addContMetaData("recvNo",nlsCreditInfoVO.getRecvAccount());
        // 年利率
        addContMetaData("yRate", Objects.nonNull(nlsCreditInfoVO.getApproveRateY()) ? nlsCreditInfoVO.getApproveRateY().multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP).toString() : "0.00");
    }

    protected abstract void setSpecifiedLoanContMedaData(T t) throws BizException;


}
